/**
 * 程序集:PM.JSVisitorDb, Version=1.1.7551.28747, Culture=neutral, PublicKeyToken=null;
 * 类名:PM.JSVisitorDb.Controllers.JsDbController
 *
 */

import type { JCRequestOption } from '../ServiceBase';
import { ServiceBase } from '../ServiceBase';
import { ApiPre } from '../../config';

const urlbase = `${ApiPre}/jsdb`;

export class JsdbService extends ServiceBase {
  SaveModelType(modelType: string, model: string, remark: string, option: JCRequestOption = {}) {
    return this.request<number>(`${urlbase}/SaveModelType`, { modelType, model, remark }, option);
  }

  GetModel(modelType: string, option: JCRequestOption = {}) {
    return this.request<string>(`${urlbase}/GetModel`, { modelType }, option);
  }

  /**
   * 写日志
   */
  WriteLog(models: LogForJs[], option: JCRequestOption = {}) {
    return this.request<boolean>(`${urlbase}/WriteLog`, { models }, option);
  }

  /**
   * 获取日志
   */
  GetLogs(condition: LogCondition, option: JCRequestOption = {}) {
    return this.request<logforjs[]>(`${urlbase}/GetLogs`, { condition }, option);
  }

  /**
   * 同步数据
   */
  SyncJsDb(orgId: number, option: JCRequestOption = {}) {
    return this.request<boolean>(`${urlbase}/SyncJsDb`, { orgId }, option);
  }
}

export class LogForJs {
  Content: string = '';
  /**
   * 关键词
   */
  KeyWord: string = '';
  /**
   * 等级
   */
  Level: number = 0;
  /**
   * 原始数据
   */
  SourceData: string = '';

  WriteTime: string = '';
}

export class LogCondition {
  SessionId: string = '';

  AccountId: number | null = null;

  Start: string = '';

  End: string = '';
}

export class logforjs {
  AutoId: number = 0;

  SessionId: string = '';

  SoftSign: string = '';

  AccountId: number = 0;

  Content: string = '';
  /**
   * 关键词
   */
  KeyWord: string = '';
  /**
   * 等级
   */
  Level: number = 0;
  /**
   * 原始数据
   */
  SourceData: string = '';
  /**
   * 日志执行时间
   */
  WriteTime: string = '';

  CreateTime: string = '';
}
